﻿using Sirenix.OdinInspector;
using System;
using System.Collections.Generic;
using UnityEngine;


//[Serializable]
public struct BaseTValue<TKey, TValue> : IEquatable<BaseTValue<TKey, TValue>>
{
    [HideInInspector]
    public TKey Type;
    [HideInInspector]
    public string TypeStr;

    [LabelWidth(70)]
    [LabelText("$Type")]
    public TValue Value;

    public BaseTValue(TKey type, TValue value)
    {
        this.Type = type;
        this.Value = value;
        this.TypeStr = type.ToString();


    }

    public BaseTValue(TKey type)
    {
        this.Type = type;
        this.Value = default;
        this.TypeStr = type.ToString();
    }

    public void SetValue(TValue value)
    {
        this.Value = value;
    }


    public bool Equals(BaseTValue<TKey, TValue> other)
    {
        return this.TypeStr == other.TypeStr && EqualityComparer<TValue>.Default.Equals(this.Value, other.Value);
    }
}